<?
$row = 12;
$col = 1;
$cat = 0;
if ($_REQUEST['cat'] != '')
    $cat = killInjection($_REQUEST['cat']);
$p = 0;
if ($_REQUEST['p'] != '')
    $p = $_REQUEST['p'];
$sql = "select id,name,image,price from tbl_product where parent in (select id from tbl_product_category where parent=".$cat." or id =".$cat.")".
    " order by price asc limit " . $row * $col * $p . "," . $row * $col;
$result = @mysql_query($sql, $conn);
$category = getRecord("tbl_product_category", "id=" . $cat);
$total = countRecord("tbl_product", " parent in (select id from tbl_product_category where parent=".$cat." or id =".$cat.")");
/*
*/
?>
 <div class="product-listing">
	<div class="title_left_bg">
    </div>
    <div class="title_center_bg">
    <div class="title_center_icon">
    </div>
    <? include ("module/processTitle.php") ?></div>
    <div class="title_right_bg"></div>
    <ul class="clearfix">
<?
if ($total == 0) {
    echo "Sản phẩm đang cập nhập.";
} else {
    for ($i = 0; $i < $row; $i++) {
        for ($j = 0; $j < $col && $products = mysql_fetch_assoc($result); $j++) {
            $pro = getRecord("tbl_product", "id=" . $products['id']);
            $strLinkFriendly = unicodeToNonUnicode($pro["name"]);
            ?>
		<li class="product">
            <div class="product-item">
                <div class="name_thumb">
                	<a title="<?=$pro["name"]?>" href="/khohangtot/product-detail/<?= $pro['id'] ?>/<?=$strLinkFriendly?>.htm" class="title"><?= substr($pro["name"],
                0, 40) ?>..</a>
                    <img title="<?=$pro["name"]?>"  src="/khohangtot/images/icon_hot_png.gif"/>
                </div><!--end .name_thumb-->
                <a title="<?=$pro["name"]?>" href="/khohangtot/product-detail/<?= $pro['id'] ?>/<?=$strLinkFriendly?>.htm" class="thumb">
                <? if ($pro["image"] == '') { ?>
                    <img title="<?=$pro["name"]?>"  src="/khohangtot/images/spm.jpg" width="140" height="140" border="0" />
                <? } else { ?>
                    <img title="<?=$pro["name"]?>"  src="/khohangtot/images/product/images/<?= $pro["image"] ?>" width="140" height="140" border="0" />
                <? } ?>
                </a>
                <span>Giá bán: </span><span class="price">&nbsp<?= number_format($pro['price'],
            0) ?> 
                            &nbsp;<?= $currencyUnit ?></span>
                <a title="<?=$pro["name"]?>" onclick="javascript:return confirm('Bạn có muốn mua sản phẩm này không ?')" 
                href="/khohangtot/<?= $pro['id'] ?>/add-to-cart.htm">
                <img title="Đặt mua <?=$pro["name"]?>"  src="/khohangtot/images/chonsp.png" class="add-to-cart"/>
                </a>
            </div>
        </li>
        <? }
    } ?>
    </ul><!--end .clearfix-->
</div><!--end .product-listing-->

<div class="page-bottom">
Trang : 
    <span>
<?
$titleFirst = $_lang == "vn" ? "Đầu" : "First";
$titlePrevious = $_lang == "vn" ? "Trước" : "Previous";
$titleNext = $_lang == "vn" ? "Sau" : "Next";
$titleLast = $_lang == "vn" ? "Cuối" : "Last";
$pages = countPages($total, $row * $col);
$param = "";
?>
<? if ($p > 1)
    echo '<a title="khohangtot| do gia dung" " href="/khohangtot/list_product/'. $_REQUEST['cat'].'/0/do-gia-dung'.rand().'.htm' .
         '">' . $titleFirst . '[&lt;&lt;]</a> ';
if ($p > 0)
    echo '<a title="khohangtot| do gia dung" " href="/khohangtot/list_product/'. $_REQUEST['cat'] .'/'. ($p - 1).'/do-gia-dung'.rand().'.htm'. 
        '">' . $titlePrevious . '</a> ';
$from = ($p - 12 > 0 ? $p - 12 : 0);
$to = ($p + 12 < $pages ? $p + 12 : $pages);
for ($i = $from; $i < $to; $i++) {
    if ($i != $p)
        echo '<a title="khohangtot| do gia dung" href="/khohangtot/list_product/'. $_REQUEST['cat'].'/'. $i .'/do-gia-dung'.rand().'.htm'. 
            '">' . ($i + 1) . ' </a>';
    else
        echo '<a title="khohangtot| do gia dung" class="select-a">' . ($i + 1) . '</a> ';
} ?>
<? if ($p < $i - 1)
    echo '<a title="khohangtot| do gia dung" ' . $titleNext . '" href="/khohangtot/list_product/'. $_REQUEST['cat'].'/'.($p + 1) .'/do-gia-dung'.rand().'.htm'. 
        '">' . $titleNext . '</a> '; ?>  <? if ($p < $pages - 1)
    echo '<a title="khohangtot| do gia dung" ' . $titleLast . '" href="/khohangtot/list_product/'. $_REQUEST['cat'].'/'.($pages - 1) .'/do-gia-dung'.rand().'.htm'. 
        '">' . $titleLast . '</a>'; ?>
    </span>
</div>
<? } ?>